﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.Ccr.Core;
using Microsoft.Dss.Core.Attributes;
using Microsoft.Dss.ServiceModel.Dssp;
using Microsoft.Dss.ServiceModel.DsspServiceBase;
using W3C.Soap;

namespace AI
{
    /// <summary>
    /// AI contract class
    /// </summary>
    public sealed class Contract
    {
        /// <summary>
        /// DSS contract identifer for AI
        /// </summary>
        [DataMember]
        public const string Identifier = "http://schemas.tempuri.org/2008/10/ai.html";
    }

    /// <summary>
    /// AI state
    /// </summary>
    [DataContract]
    public class AIState
    {
    }


    [DataContract]
    public class UrbanLRFInfoState
    {

        [DataMember]
        public int _Angle = 0;

    }


    [DataContract]
    public class UrbanGPSInfoState
    {

        [DataMember]
        public double YDiff = 0;

        [DataMember]
        public double XDiff = 0;

        [DataMember]
        public double CurrentLatitude = 0;

        [DataMember]
        public double CurrentLongitude = 0;

    }



    [DataContract]
    public class UrbanSignalState
    {

        [DataMember]
        public uint RCount = 0;

        [DataMember]
        public uint GCount = 0;


        [DataMember]
        public uint LeftCount = 0;

        [DataMember]
        public uint RightCount = 0;

        public override string ToString()
        {
            return "R :" + RCount.ToString() +"," + "G :" + GCount.ToString();
        }
    }

    //[DataContract]
    //public class UrbanDestInfoState
    //{
    //    [DataMember]
    //    public double StartLatitude = 0;

    //    [DataMember]
    //    public double StartLongitude = 0;

    //    [DataMember]
    //    public double EndLatitude = 0;

    //    [DataMember]
    //    public double EndLongitude = 0;

    //}

    [DataContract]
    public class DriveInfo
    {
        [DataMember]
        public double left = 0;

        [DataMember]
        public double right = 0;
    }

    [DataContract]
    public class TargetInfoState
    {
        [DataMember]
        public double TargetLatitude = 0;

        [DataMember]
        public double TargetLongitude = 0;
    }

    [DataContract]
    public class EventCamUpdateState
    {
        [DataMember]
        public bool bUpdate = false;

    }

    [DataContract]
    public class UrbanCamState
    {
        [DataMember]
        public string CamUriName = "";
    }



    public class Connect : Update<UrbanCamState, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public Connect()
        {
        }

        public Connect(UrbanCamState body)
            : base(body)
        {
        }
    }

    /// <summary>
    /// AI main operations port
    /// </summary>
    [ServicePort]
    public class AIOperations : PortSet<Connect,DsspDefaultLookup, DsspDefaultDrop, Get, Subscribe, GpsUpdate, NotifyDrive, UrbanSignal, LRFUpdate, TargetInfo, EventCamUpdate>
    {
    }


    public class TargetInfo : Update<TargetInfoState, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public TargetInfo()
        {
        }

        public TargetInfo(TargetInfoState body)
            : base(body)
        {
        }
    }

    public class UrbanSignal : Update<UrbanSignalState, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public UrbanSignal()
        {
        }

        public UrbanSignal(UrbanSignalState body)
            : base(body)
        {
        }
    }


    public class EventCamUpdate : Replace<EventCamUpdateState, PortSet<DefaultReplaceResponseType, Fault>>
    {
        public EventCamUpdate()
        {
        }

        public EventCamUpdate(EventCamUpdateState body)
            :
            base(body)
        {
        }
    }


    public class NotifyDrive : Replace<DriveInfo, PortSet<DefaultReplaceResponseType, Fault>>
    {
        public NotifyDrive()
        {
        }

        public NotifyDrive(DriveInfo body)
            :
            base(body)
        {
        }
    }

    public class GpsUpdate : Update<UrbanGPSInfoState, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public GpsUpdate()
        {
        }

        public GpsUpdate(UrbanGPSInfoState body)
            : base(body)
        {
        }
    }



    public class LRFUpdate : Update<UrbanLRFInfoState, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public LRFUpdate()
        {
        }

        public LRFUpdate(UrbanLRFInfoState body)
            : base(body)
        {
        }
    }

    //public class DestInfoUpdate : Update<UrbanDestInfoState, PortSet<DefaultUpdateResponseType, Fault>>
    //{
    //    public DestInfoUpdate()
    //    {
    //    }

    //    public DestInfoUpdate(UrbanDestInfoState body)
    //        : base(body)
    //    {
    //    }
    //}

    /// <summary>
    /// AI get operation
    /// </summary>
    public class Get : Get<GetRequestType, PortSet<AIState, Fault>>
    {
        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        public Get()
        {
        }

        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        /// <param name="body">the request message body</param>
        public Get(GetRequestType body)
            : base(body)
        {
        }

        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        /// <param name="body">the request message body</param>
        /// <param name="responsePort">the response port for the request</param>
        public Get(GetRequestType body, PortSet<AIState, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }

    /// <summary>
    /// AI subscribe operation
    /// </summary>
    public class Subscribe : Subscribe<SubscribeRequestType, PortSet<SubscribeResponseType, Fault>>
    {
        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        public Subscribe()
        {
        }

        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        /// <param name="body">the request message body</param>
        public Subscribe(SubscribeRequestType body)
            : base(body)
        {
        }

        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        /// <param name="body">the request message body</param>
        /// <param name="responsePort">the response port for the request</param>
        public Subscribe(SubscribeRequestType body, PortSet<SubscribeResponseType, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }
}


